import request from "@/utils/request";
import { parseStrEmpty } from "@/utils/frameWork";

// 查询任务列表
export function listTask(query) {
  return request({
    url: "/supervision/task/list",
    method: "get",
    params: query,
  });
}

// 查询任务详细
export function getCheckTask(id) {
  return request({
    url: "/supervision/task/" + parseStrEmpty(id),
    method: "get",
  });
}
// 新增任务
export function addCheckTask(data) {
  return request({
    url: "/supervision/task/",
    method: "post",
    data: data,
  });
}
// 删除任务
export function delCheckTask(caseId) {
  return request({
    url: "/supervision/task/" + caseId,
    method: "delete",
  });
}
// 修改任务
export function updateCheckTask(data) {
  return request({
    url: "/supervision/task/",
    method: "put",
    data: data,
  });
}
// 获取所有案件列表
export function getCaseList(data) {
  return request({
    url: "/supervision/caseManagement/getCaseList",
    method: "post",
    data: data,
  });
}
// 由任务id获取涉案人信息列表
export function getPersonListByTaskId(data) {
  return request({
    url: "/supervision/involvedPerson/getPersonListByTaskId",
    method: "post",
    data: data,
  });
}
// 退回任务
export function returnTask(data) {
  return request({
    url: "/supervision/task/returnTask",
    method: "post",
    data: data,
  });
}
//
export function claimTask(data) {
  return request({
    url: "/supervision/task/claimTask",
    method: "post",
    data: data,
  });
}
// 完成任务
export function completeTask(data) {
  return request({
    url: "/supervision/task/completeTask",
    method: "post",
    data: data,
  });
}
// 文件预览
export function onlinePreview(filename) {
  return request({
    url: "/file/onlinePreview?filename=" + filename,
    method: "post",
    responseType: "blob",
  });
}
export function downloadFile(data) {
  return request({
    url: "/file/downloadFile",
    method: "post",
    data: data,
    responseType: "blob",
  });
}
export function download(url, name) {
  const a = document.createElement("a");
  a.download = name;
  a.href = url;
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
}
// 所属区县
export function getChildXzqhk(oucode) {
  return request({
    url: "/supervision/xzqh/getChildXzqh?bm=" + oucode,
    method: "get",
  });
}
// 所属区县
export function queryByFjbm(oucode) {
  return request({
    url: "/supervision/tjczdxx/queryByFjbm?fjbm=" + oucode,
    method: "get",
  });
}
// 批量导入
export function batchInsert(data) {
  return request({
    url: "/supervision/task/batchInsert",
    method: "post",
    data: data,
  });
}
